<template>

	<el-form :model="user" label-width="120px">
		<el-form-item label="姓名">
			<el-input v-model="user.userName" />
		</el-form-item>
		<el-form-item label="性别">
			<el-radio-group v-model="user.userSex" class="ml-4">
				<el-radio label="男" size="large">男 </el-radio>
				<el-radio label="女" size="large">女 </el-radio>
			</el-radio-group>
		</el-form-item>

		<el-form-item label="年龄">
			<el-input v-model="user.userAge" />
		</el-form-item>

		<el-form-item label="身份证号">
			<el-input v-model="user.userIdcardnum" />
		</el-form-item>

		<el-form-item label="家庭住址">
			<el-input v-model="user.userHomeadress" />
		</el-form-item>

		<el-form-item label="手机号码">
			<el-input v-model="user.userPhonenum" />
		</el-form-item>
		
		<el-form-item label="系统用户名">
			<el-input v-model="user.userLoginame" />
		</el-form-item>
		
		<el-form-item label="系统密码">
			<el-input v-model="user.userPassword" />
		</el-form-item>

		<el-form-item label="进入部门">
			<el-select v-model="user.userDepartment" placeholder="please select your zone" @change="dpmchange">
				<el-option label="业务部" value="业务部" />
				<el-option label="人事部" value="人事部" />
				<el-option label="财务部" value="财务部" />
				<el-option label="项目部" value="项目部" />
			</el-select>
		</el-form-item>

		<el-form-item label="职位">
			<el-select v-model="user.postName" placeholder="please select your zone">
					<el-option v-for="item in posts" :label="item.postName" :value="item.postName" />
			</el-select>
		</el-form-item>


		<el-form-item label="权限等级">
			<el-select v-model="user.userPower" placeholder="please select your zone">
				<el-option label="1" value="1" />
				<el-option label="2" value="2" />
				<el-option label="3" value="3" />
				<el-option label="4" value="4" />
			</el-select>
		</el-form-item>


		<el-form-item label="月薪">
			<el-input v-model="user.userSalary" style="width: 100ox;" />
		</el-form-item>

		<el-form-item>
			<el-button type="primary" @click="onSubmit">创建</el-button>
			<el-button>取消</el-button>
		</el-form-item>
	</el-form>


</template>>
<script>
	import qs from 'qs'
	export default {
		data() {
			return {
				user: {
					userLoginame: '',
					userPassword: '',
					userName: '',
					userSex: '',
					userAge: 0,
					userIdcardnum: '',
					userHomeadress: '',
					userPhonenum: '',
					userDepartment: '',
					postName: '',
					userPower: '',
					userSalary: 0,
					userIsonjob: '是',
				},
				post: {
					postName: '',
					postDepartment: '',
				},
				posts: [],
			}
		},
		methods: {
			onSubmit() {
				console.log(this.user)
				let that = this
				let str = qs.stringify(this.user)
				this.$axios.get("http://localhost:8080/user/insert?" + str).then(function(res) {
					console.log(res);
				})
			},
			dpmchange() {
				this.post.postDepartment = this.user.userDepartment
				let that = this
				let str = qs.stringify(this.post)
				console.log(this.post)
				this.$axios.get("http://localhost:8080/post/search?" + str).then(function(res) {
					console.log(res);
					that.posts = res.data;
					console.log(that.posts);
				})
			}
		},
		created() {}

	}
</script>
